import static org.junit.Assert.fail;

import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.Select;


public class SBETest {
	private WebDriver driver;
	private String baseUrl;
	private StringBuffer verificationErrors = new StringBuffer();
	@Before
	public void setUp() throws Exception {
		driver = new InternetExplorerDriver();
		baseUrl = "http://dev09.dev.dssproj.com/";
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	}
@Test
public void test1(){
	driver.get(baseUrl + "/uk-en/");
	driver.findElement(By.linkText("United Kingdom")).click();
	driver.findElement(By.id("edit-adult")).click();
	driver.findElement(By.id("edit-adult")).clear();
	driver.findElement(By.id("edit-adult")).sendKeys("2");
	driver.findElement(By.id("edit-youth")).clear();
	driver.findElement(By.id("edit-youth")).sendKeys("2");
	driver.findElement(By.id("edit-senior")).clear();
	driver.findElement(By.id("edit-senior")).sendKeys("2");
	driver.findElement(By.id("dialog-element")).click();
	driver.findElement(By.xpath("//form[@id='standard-booking-path-daily-view-form']/div/div[3]/table/tbody/tr[7]/td[6]/div")).click();
	driver.findElement(By.id("cart-continue-top")).click();
	driver.findElement(By.id("cart-continue-top")).click();
	driver.findElement(By.cssSelector("#dialog-dialog-element--3 > div.item-list > ul..count-2 > li.first > a.button.ok")).click();
	driver.findElement(By.id("dialog-element--3")).click();
	new Select(driver.findElement(By.id("edit-adult-qdendp-1-1-title"))).selectByVisibleText("Mr");
	driver.findElement(By.id("edit-adult-qdendp-1-1-first-name")).clear();
	driver.findElement(By.id("edit-adult-qdendp-1-1-first-name")).sendKeys("abcd");
	driver.findElement(By.id("edit-adult-qdendp-1-1-last-name")).clear();
	driver.findElement(By.id("edit-adult-qdendp-1-1-last-name")).sendKeys("efgh");
	new Select(driver.findElement(By.id("edit-adult-qdendp-1-1-meal"))).selectByVisibleText("Standard");
	new Select(driver.findElement(By.id("edit-adult-qdendp-2-1-title"))).selectByVisibleText("Miss");
	driver.findElement(By.id("edit-adult-qdendp-2-1-first-name")).clear();
	driver.findElement(By.id("edit-adult-qdendp-2-1-first-name")).sendKeys("joe");
	driver.findElement(By.id("edit-adult-qdendp-2-1-last-name")).clear();
	driver.findElement(By.id("edit-adult-qdendp-2-1-last-name")).sendKeys("bloggs");
	new Select(driver.findElement(By.id("edit-adult-qdendp-2-1-meal"))).selectByVisibleText("Standard");
	new Select(driver.findElement(By.id("edit-youth-qdendp-5-1-title"))).selectByVisibleText("Mr");
	driver.findElement(By.id("edit-youth-qdendp-5-1-first-name")).clear();
	driver.findElement(By.id("edit-youth-qdendp-5-1-first-name")).sendKeys("jimmy");
	driver.findElement(By.id("edit-youth-qdendp-5-1-last-name")).clear();
	driver.findElement(By.id("edit-youth-qdendp-5-1-last-name")).sendKeys("bloggs");
	new Select(driver.findElement(By.id("edit-youth-qdendp-5-1-meal"))).selectByVisibleText("Standard");
	new Select(driver.findElement(By.id("edit-youth-qdendp-6-1-title"))).selectByVisibleText("Miss");
	driver.findElement(By.id("edit-youth-qdendp-6-1-first-name")).clear();
	driver.findElement(By.id("edit-youth-qdendp-6-1-first-name")).sendKeys("efgh");
	driver.findElement(By.id("edit-youth-qdendp-6-1-last-name")).clear();
	driver.findElement(By.id("edit-youth-qdendp-6-1-last-name")).sendKeys("hijk");
	new Select(driver.findElement(By.id("edit-youth-qdendp-6-1-meal"))).selectByVisibleText("Standard");
	new Select(driver.findElement(By.id("edit-senior-qdendp-3-1-title"))).selectByVisibleText("Mr");
	driver.findElement(By.id("edit-senior-qdendp-3-1-first-name")).clear();
	driver.findElement(By.id("edit-senior-qdendp-3-1-first-name")).sendKeys("sree");
	driver.findElement(By.id("edit-senior-qdendp-3-1-last-name")).clear();
	driver.findElement(By.id("edit-senior-qdendp-3-1-last-name")).sendKeys("kanth");
	new Select(driver.findElement(By.id("edit-senior-qdendp-3-1-meal"))).selectByVisibleText("Standard");
	new Select(driver.findElement(By.id("edit-senior-qdendp-4-1-title"))).selectByVisibleText("Mr");
	driver.findElement(By.id("edit-senior-qdendp-4-1-first-name")).clear();
	driver.findElement(By.id("edit-senior-qdendp-4-1-first-name")).sendKeys("hiran");
	driver.findElement(By.id("edit-senior-qdendp-4-1-last-name")).clear();
	driver.findElement(By.id("edit-senior-qdendp-4-1-last-name")).sendKeys("shetty");
	new Select(driver.findElement(By.id("edit-senior-qdendp-4-1-meal"))).selectByVisibleText("Standard");
	driver.findElement(By.id("dialog-element--2")).click();
}
	@After
	public void tearDown() throws Exception {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}

	private boolean isElementPresent(By by) {
		try {
			driver.findElement(by);
			return true;
		} catch (NoSuchElementException e) {
			return false;
		}
	}
}



